package com.hxkcloud.patient.aerotel.domain.health;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;

import com.hxkcloud.patient.aerotel.enumeration.HealthDeviceType;


/**
 * Created by daipengfei on 16/3/11.
 */
public class HealthDevice {

    private String sn;
    private String name;

    private String btmac;

    public String getBtmac() {
        return btmac;
    }

    public void setBtmac(String btmac) {
        this.btmac = btmac;
    }

    private HealthDeviceType type = HealthDeviceType.ECG;


    public HealthDeviceType getType() {
        return type;
    }

    public void setType(HealthDeviceType type) {
        this.type = type;
    }

    public HealthDevice() {
    }

    public HealthDevice(String mac, HealthDeviceType type) {
        this.btmac = mac;
        this.type = type;
    }

    public HealthDevice(BluetoothDevice device, HealthDeviceType type) {
        this.name = device.getName();
        this.btmac = device.getAddress();
        this.type = type;
    }

    public HealthDevice(BluetoothDevice device) {
        this(device, HealthDeviceType.ECG);
    }

    public BluetoothDevice getDevice() {
        BluetoothDevice btd = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(btmac);
        return btd;
    }

    public boolean isBond() {
        BluetoothDevice btd = getDevice();
        return (btd.getBondState() == BluetoothDevice.BOND_BONDED);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSn() {
        return sn;
    }

    public void setSn(String sn) {
        this.sn = sn;
    }
}
